package com.plian.system.service.fr.evaluation.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.fr.evaluation.EvaluationValue;
import com.plian.system.mapper.fr.evaluation.EvaluationValueMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.fr.evaluation.IEvaluationValueService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 评估价值 服务实现类
 *
 * @author jianglei
 * @since 2019-10-21
 */
@Slf4j
@Service
@AllArgsConstructor
public class EvaluationValueServiceImpl extends BaseServiceImpl<EvaluationValueMapper, EvaluationValue> implements IEvaluationValueService {

	@Override
	public Boolean deleteLogicByEvaluationApprovalId(List<Long> ids) {
		LambdaQueryWrapper<EvaluationValue> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.in(EvaluationValue::getEvaluationApprovalId, ids);
		List<EvaluationValue> evaluationValues = list(queryWrapper);
		if (CollectionUtil.isNotEmpty(evaluationValues)){
			return deleteLogic(evaluationValues.stream().map(EvaluationValue::getId).collect(Collectors.toList()));
		}
		return true;
	}
}
